namespace CLELCore.Assembly.CLELInstructions
{
	public class Stloc : ObjectModel
	{
		private ushort _local;
		public ushort Local
		{
			get
			{
				return _local;
			}
			set
			{
				_local = value;
			}
		}
		public override int Length
		{
			get
			{
				return 4;
			}
		}
		public Stloc(ushort local) : base(CLELOpcode.OBJECTMODEL,CLELOpcode.STLOC)
		{
			_local = local;
		}

		public override byte[] GetBytes(bool little_endian)
		{
			byte[] ret = new byte[4];
			ret[0] = CLELOpcode.OBJECTMODEL;
			ret[1] = CLELOpcode.STLOC;
			int i,j;
			if(little_endian)
				j = 0;
			else
				j = 1;
			for(i = 2;i < 4;i++)
			{
				ret[i] = Bits.ByteFromUnsignedShort(j,_local);
				if(little_endian)
					j++;
				else
					j--;
			}
			return ret;
		}
		
		public override string ToString()
		{
			return "stloc " + _local;
		}
	}
}
